Array.prototype.isHave = function (needle) {
    for (let i in this) {
        if (this[i] == needle) return true;
    }
    return false;
}
Array.prototype.random = function () {
    let maxPos = this.length
    return this[Math.floor(Math.random() * maxPos)]
}

let randomStringList = [0]
String.prototype.random = function (len) {
    len = len || 32;
    let chars
    if (this === '') {
        chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz23456789'
    } else {
        chars = this
    }
    let maxPos = chars.length
    let pwd = ''
    for (let i = 0; i < len; i++) {
        pwd += chars.charAt(Math.floor(Math.random() * maxPos));
    }
    let isHave = randomStringList.isHave(pwd)
    if (isHave) {
        pwd = this.random(len)
    }
    randomStringList.push(pwd)
    return pwd
}
String.prototype.styleCut = (value = null, cut, style, reg = /-/g) => {
    value = value || this
    value = value.replace(reg, '')
    let p = ''
    for (let i = 0; i < value.length; i++) {
        let str = value.charAt(i)
        p += str
        for (let i2 = 0; i2 < cut.length; i2++) {
            if (i + 1 === cut[i2]) {
                p += style
            }
        }
    }
    return p
}


if (!Array.prototype.map) {
    Array.prototype.map = function (callback, thisArg) {
        var T, A, k;
        if (this == null) {
            throw new TypeError(" this is null or not defined");
        }
        // 1. 将O赋值为调用map方法的数组.
        var O = Object(this);
        // 2.将len赋值为数组O的长度.
        var len = O.length >>> 0;
        // 3.如果callback不是函数,则抛出TypeError异常.
        if (Object.prototype.toString.call(callback) != "[object Function]") {
            throw new TypeError(callback + " is not a function");
        }
        // 4. 如果参数thisArg有值,则将T赋值为thisArg;否则T为undefined.
        if (thisArg) {
            T = thisArg;
        }
        // 5. 创建新数组A,长度为原数组O长度len
        A = new Array(len);
        // 6. 将k赋值为0
        k = 0;
        // 7. 当 k < len 时,执行循环.
        while (k < len) {
            var kValue, mappedValue;
            //遍历O,k为原数组索引
            if (k in O) {
                //kValue为索引k对应的值.
                kValue = O[k];
                // 执行callback,this指向T,参数有三个.分别是kValue:值,k:索引,O:原数组.
                mappedValue = callback.call(T, kValue, k, O);
                // 返回值添加到新数组A中.
                A[k] = mappedValue;
            }
            // k自增1
            k++;
        }
        // 8. 返回新数组A
        return A;
    };
}
